package cn.tiancaifan.micro.service;


import cn.tiancaifan.micro.entity.Oplog;
import cn.tiancaifan.micro.entity.SystemResults;
import cn.tiancaifan.micro.mapper.OplogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * (Oplog)表服务接口
 *
 * @author makejava
 * @since 2020-06-08 09:28:16
 */
@Service
public class OplogService {

    @Autowired
    OplogMapper oplogMapper;
    /**
     * 新增数据
     *
     * @param oplog 实例对象
     * @return 实例对象
     */
    public Oplog saveLog(Oplog oplog) {
        oplogMapper.saveLog(oplog);
        return oplog;
    }

    @Transactional
    public SystemResults getOplogByPage(Integer page, Integer size) {
        List<Oplog> oplogs = oplogMapper.getOplogByPage(page,size);
        int total = oplogMapper.getTotal();
        SystemResults ok = SystemResults.ok(null, oplogs);
        ok.setTotal(total);
        return ok;
    }

}